package com.quanquan.user.controller;

import DTO.PageDTO;
import com.quanquan.user.dto.AbnormalConsumptionDTO;
import com.quanquan.user.request.AbnormalConsumptionRequest;
import com.quanquan.user.service.AbnormalConsumptionService;
import enums.ResCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import web.response.ResultBody;

/**
 * @ClassName:AbnormalConsumptionController
 * @Description:TODO
 * @Author:xiongjunbao
 * @Date:2019/8/23 17:04
 * @Version 1.0
 */
@RestController
@RequestMapping("/abnormal_consumption")
public class AbnormalConsumptionController {

    private final AbnormalConsumptionService abnormalConsumptionService;

    @Autowired
    public AbnormalConsumptionController(AbnormalConsumptionService abnormalConsumptionService) {
        this.abnormalConsumptionService = abnormalConsumptionService;
    }

    @PostMapping("/query_menegement")
    public ResultBody queryMenegement(@RequestBody AbnormalConsumptionRequest request){
        PageDTO<AbnormalConsumptionDTO> pageDTO = abnormalConsumptionService.queryMenegement(request);
        if (pageDTO==null||pageDTO.getList().size()<=0){
            return new ResultBody(ResCodeEnum.NO_DATA.getCode(), ResCodeEnum.NO_DATA.getMsg());
        }
        return new ResultBody(ResCodeEnum.SUCCESS.getCode(), ResCodeEnum.SUCCESS.getMsg(),pageDTO);
    }





}
